package com.hotelvip.controller;

import com.hotelvip.common.utils.JSONResult;
import com.hotelvip.entity.Label;
import com.hotelvip.service.LabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;




/**
 * @author ypb
 * @Date:2021/1/20
 */
@RestController
@RequestMapping("/label")
@Api(basePath = "/label",tags = "特殊需求标签管理")
public class LabelController {

    @Autowired
    private LabelService labelService;

    @ApiOperation(value = "根据用户特殊需求添加/修改",httpMethod = "POST")
    @PostMapping("/updateLabelById")
    public JSONResult updateLabel(@RequestParam("userId") Long userId, @RequestBody List<Label> labels){
        labelService.updateLabelById(userId,labels);
        return JSONResult.ok();
    }

    @ApiOperation(value = "查询所有特殊需求",httpMethod = "GET")
    @GetMapping("/selectLabel")
    public JSONResult selectLabel(){
        return JSONResult.ok(labelService.selectAllLabel());
    }

    @ApiOperation(value = "删除特殊需求",httpMethod = "DELETE")
    @DeleteMapping("/deleteLabel")
    public JSONResult deleteLabel(@RequestParam List<Integer> labelIds){
        labelService.deleteLabel(labelIds);
        return JSONResult.ok();
    }


    @ApiOperation(value = "新增新标签",httpMethod = "POST")
    @PostMapping("/insertLabels")
    public JSONResult insertLabels(@RequestParam List<String> labels){
        labelService.insertLabels(labels);
        return JSONResult.ok();
    }

    @ApiOperation(value = "根据用户的id查询用户的标签",httpMethod = "GET")
    @GetMapping("/selectLabelById")
    public JSONResult selectLabelById(@RequestParam Long userId){
        return JSONResult.ok(labelService.selectLabelById(userId));
    }

}
